/**
 * 
 */
package kr.co.insoft.driver.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;

import kr.co.insoft.driver.util.NullExcludeTransformer;
import flexjson.JSONSerializer;

/**
 * @author IN-SOFT Inc. GoodwillDD(sylee@in-soft.co.kr)
 * 
 */
public class InstanceResultModel implements Serializable {

	private static final long serialVersionUID = -3041846845979606094L;
	Collection<String> groupNames;
	Collection<? extends GroupModel> groups;
	Collection<? extends InstanceModel> instances;
	String ownerId;
	String requestId; /* job id ? */
	String reservationId; /* job id ? */

	public InstanceResultModel() {

	}

	public String toString() {
		return (new JSONSerializer())
				.transform(new NullExcludeTransformer(), void.class)
				.exclude("*.class").deepSerialize(this);
	}

	public Collection<String> getInstanceIds() {
		Collection<String> instanceIds = new HashSet<String>();
		for (InstanceModel instance : this.getInstances()) {
			instanceIds.add(instance.getInstanceId());
		}
		return instanceIds;
	}

	/**
	 * @return the groupNames
	 */
	public Collection<String> getGroupNames() {
		return groupNames;
	}

	/**
	 * @param groupNames
	 *            the groupNames to set
	 */
	public void setGroupNames(Collection<String> groupNames) {
		this.groupNames = groupNames;
	}

	/**
	 * @return the groups
	 */
	public Collection<? extends GroupModel> getGroups() {
		return groups;
	}

	/**
	 * @param groups
	 *            the groups to set
	 */
	public void setGroups(Collection<? extends GroupModel> groups) {
		this.groups = groups;
	}
	
	/**
	 * @return the instances
	 */
	public Collection<? extends InstanceModel> getInstances() {
		return instances;
	}

	/**
	 * @param instances
	 *            the instances to set
	 */
	public void setInstances(Collection<? extends InstanceModel> instances) {
		this.instances = instances;
	}

	/**
	 * @return the ownerId
	 */
	public String getOwnerId() {
		return ownerId;
	}

	/**
	 * @param ownerId
	 *            the ownerId to set
	 */
	public void setOwnerId(String ownerId) {
		this.ownerId = ownerId;
	}

	/**
	 * @return the requestId
	 */
	public String getRequestId() {
		return requestId;
	}

	/**
	 * @param requestId
	 *            the requestId to set
	 */
	public void setRequestId(String requestId) {
		this.requestId = requestId;
	}

	/**
	 * @return the reservationId
	 */
	public String getReservationId() {
		return reservationId;
	}

	/**
	 * @param reservationId
	 *            the reservationId to set
	 */
	public void setReservationId(String reservationId) {
		this.reservationId = reservationId;
	}
}
